From c705b05a310d753c900aa76fff6f3e9cb3e37769 Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Thu, 30 Mar 2006 11:51:44 +0100 Subject: [PATCH] Fix the ProtocolError seen when the server throws an exception and running under Python 2.3; traceback.format_exc was introduced in 2.4, so we can't use it. Added some exception logging. Signed-off-by: Ewan Mellor --- tools/python/xen/util/xmlrpclib2.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/python/xen/util/xmlrpclib2.py b/tools/python/xen/util/xmlrpclib2.py index 538cbd8a95..214a678fac 100644 --- a/tools/python/xen/util/xmlrpclib2.py +++ b/tools/python/xen/util/xmlrpclib2.py @@ -23,9 +23,13 @@ An enhanced XML-RPC client/server interface for Python. from httplib import HTTPConnection, HTTP from xmlrpclib import Transport from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler -import xmlrpclib, socket, os, traceback +import xmlrpclib, socket, os import SocketServer +import xen.xend.XendClient +from xen.xend.XendLogging import log + + # A new ServerProxy that also supports httpu urls. An http URL comes in the # form: # @@ -60,8 +64,7 @@ class ServerProxy(xmlrpclib.ServerProxy): verbose, allow_none) # This is a base XML-RPC server for TCP. It sets allow_reuse_address to -# true, and has an improved marshaller that serializes unknown exceptions -# with full traceback information. +# true, and has an improved marshaller that logs and serializes exceptions. class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer): allow_reuse_address = True @@ -80,10 +83,10 @@ class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer): allow_none=1) except xmlrpclib.Fault, fault: response = xmlrpclib.dumps(fault) - except: + except Exception, exn: + log.exception(exn) response = xmlrpclib.dumps( - xmlrpclib.Fault(1, traceback.format_exc()) - ) + xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn))) return response -- 2.30.2